Skip to content

fix(interpreter): loop/return scoping, trap listings, [[ ]] operands and builtin parity from the BashBox corpus - #2629

Merged
chaliy merged 9 commits into
mainfrom
claude/project-thread-eafupr-bb-core
Oct 8, 2026
Merged

chaliy merged 9 commits into
mainfrom
claude/project-thread-eafupr-bb-core

Conversation

@chaliy

@chaliy chaliy commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

Interpreter-core behavior now matches bash 5.2 in the areas the BashBox corpus covers:

  • Loops and return: break/continue never leave a caller's loop and warn outside one; a non-numeric count exits with 128. return with no argument returns $? and ends a sourced file.
  • Expansion errors: ${x!} and ${} report "bad substitution", ${1:=x} reports "cannot assign in this way"; both abandon the line.
  • Traps: ERR and DEBUG handlers keep $?. trap normalises signal names (0 is EXIT, int/SIGINT), rejects unknown names, and lists in bash order with re-readable quoting. alias and a bare set use the same quoting.
  • [[ ]]: -eq/-lt operands are evaluated as arithmetic; an invalid =~ regex returns 2.
  • unset: options only before the first name, bad options exit 2, -f with -v is an error, readonly elements are refused.
  • Smaller builtins: getopts always writes OPTIND (starts at 1); builtin cat says "not a shell builtin"; hash and source error statuses; pushd/dirs show ~; read -d '' splits on NUL; set -k; a[-5]=x before the start is a bad subscript.

Why

BashBox corpus batch: 47 of the 48 skipped cases in bashbox-interpreter-core.test.sh now pass. The one left needs ENOTDIR for a path under a regular file in the VFS; its skip reason says so.

Before / After

$ trap "echo b" ERR; trap "echo a" EXIT; trap "" INT; trap "it's" SIGTERM; trap
before: ERR first, then EXIT, INT; 'it's' unquotable
after:  trap -- 'echo a' EXIT / trap -- '' SIGINT / trap -- 'it'\''s' SIGTERM / trap -- 'echo b' ERR   (= bash 5.2)

$ trap "echo caught \$?" ERR; false; echo next $?
before: caught 1 / next 0        after: caught 1 / next 1

$ re='('; [[ a =~ $re ]]; echo $?; x='1+1'; [[ $x -eq 2 ]]; echo $?
before: 1 / 1                    after: 2 / 0

Risk

Checklist

  • Tests added or updated
  • Backward compatibility considered

Generated by Claude Code

@chaliy chaliy self-assigned this Oct 8, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit b8185f8 Commit Preview URL

Branch Preview URL
Oct 08 2026, 02:41 AM

@chaliy
chaliy merged commit 99e02d4 into main Oct 8, 2026
46 checks passed
@chaliy
chaliy deleted the claude/project-thread-eafupr-bb-core branch October 8, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant